﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;


    public static class DateExtend
    {
        public static DateTime SafeSqlDate(this DateTime date)
        {

            if (date > System.Data.SqlTypes.SqlDateTime.MaxValue.Value)
                return System.Data.SqlTypes.SqlDateTime.MaxValue.Value;

            if (date < System.Data.SqlTypes.SqlDateTime.MinValue.Value)
                return System.Data.SqlTypes.SqlDateTime.MinValue.Value;

            return date;

        }
    }
